import Link from "antd/es/typography/Link"
import { useSelector } from "react-redux"

import { useDigital } from "@/hooks"
import { useLocale } from "@/locales"
import { AppState } from "@/stores"

import { GameInfo } from "./components/GameInfo"

export const columnsSquidInfo = (hasPermissionAction: boolean) => {
	const { allDictLists } = useSelector((state: AppState) => state.config)
	const { newFormat, formatMessage } = useLocale()
	const { renderFormatWithCurrency } = useDigital()
	const optionsGameType = allDictLists["gameType"]
		? allDictLists["gameType"].map((item: { label: string; value: any }) => {
				return {
					label: newFormat(item.label),
					value: item.value
				}
		  })
		: []
	return [
		{
			dataIndex: "tableCode",
			title: formatMessage({ id: "member.squid_info.table_id" }),
			render: (_: any, record: any) => (
				<Link href={`/dxn/gameManager/cardTablesList/cardTablesBase?tableId=${record.tableCode}`}>{record.tableCode}</Link>
			),
			width: 150,
			align: "center",
			key: "tableCode"
		},
		{
			dataIndex: "tableName",
			title: formatMessage({ id: "member.squid_info.table_name" }),
			render: (value: any, record: any) => <p>{record.tableName || "-"}</p>,
			width: 150,
			align: "center",
			key: "tableName"
		},
		{
			dataIndex: "tableType",
			title: formatMessage({ id: "member.squid_info.game_name" }),
			render: (_text: any, record: any) => (
				<p>{optionsGameType.filter((item: { label: any; value: string }) => item.value == record.tableType)[0]?.label || "-"} </p>
			),
			width: 150,
			align: "center",
			key: "tableType"
		},
		{
			dataIndex: "squidModelName",
			title: formatMessage({ id: "member.squid_info.model" }),
			render: (value: any, record: any) => <p>{record.squidModelName || "-"}</p>,
			width: 150,
			align: "center",
			key: "squidModelName"
		},
		{
			dataIndex: "squidStatusName",
			title: formatMessage({ id: "member.squid_info.win_lose" }),
			render: (value: any, record: any) => <p>{record.squidStatusName || "-"}</p>,
			width: 150,
			align: "center",
			key: "squidStatusName"
		},
		{
			dataIndex: "settleTypeName",
			title: formatMessage({ id: "member.squid_info.method" }),
			render: (value: any, record: any) => <p>{record.settleTypeName || "-"}</p>,
			width: 150,
			align: "center",
			key: "settleTypeName"
		},
		{
			dataIndex: "round",
			title: formatMessage({ id: "member.squid_info.squid_rounds" }),
			render: (value: any, record: any) => <p>{record.round || "-"}</p>,
			width: 150,
			align: "center",
			key: "round"
		},
		{
			dataIndex: "blind",
			title: formatMessage({ id: "member.squid_info.blind" }),
			render: (value: any, record: any) => (
				<GameInfo
					tableType={record.tableType}
					bbBlindScore={record.bbBlindScore}
					sbBlindScore={record.sbBlindScore}
					anteSwitch={record.anteSwitch}
					anteScore={record.anteScore}
					straddleAmount={record.straddleAmount}
				/>
			),
			width: 150,
			align: "center",
			key: "blind"
		},
		{
			dataIndex: "squidRewardAmount",
			title: formatMessage({ id: "member.squid_info.squid_rewards" }),
			render: (_: any, record: any) => <p>{renderFormatWithCurrency(record.squidRewardAmount, record.currency)}</p>,
			width: 150,
			align: "center",
			key: "squidRewardAmount"
		},
		{
			dataIndex: "squidCompensationAmount",
			title: formatMessage({ id: "member.squid_info.squid_payouts" }),
			render: (_: any, record: any) => <p>{renderFormatWithCurrency(record.squidCompensationAmount, record.currency)}</p>,
			width: 150,
			align: "center",
			key: "squidCompensationAmount"
		},
		{
			dataIndex: "squidWalletPay",
			title: formatMessage({ id: "member.squid_info.squid_payments" }),
			render: (_: any, record: any) => <p>{renderFormatWithCurrency(record.squidWalletPay, record.currency)}</p>,
			width: 150,
			align: "center",
			key: "squidWalletPay"
		},
		{
			dataIndex: "beginHandCode",
			title: formatMessage({ id: "member.squid_info.squid_starting_id" }),
			render: (value: any, record: any) => <p>{record.beginHandCode || "-"}</p>,
			width: 190,
			align: "center",
			key: "beginHandCode"
		},
		{
			dataIndex: "beginHandNum",
			title: formatMessage({ id: "member.squid_info.squid_starting_number" }),
			render: (value: any, record: any) => <p>{record.beginHandNum}</p>,
			width: 135,
			align: "center",
			key: "beginHandNum"
		},
		{
			dataIndex: "settleHandCode",
			title: formatMessage({ id: "member.squid_info.squid_settlement_id" }),
			render: (value: any, record: any) => <p>{record.settleHandCode || "-"}</p>,
			width: 150,
			align: "center",
			key: "settleHandCode"
		},
		{
			dataIndex: "settleHandNum",
			title: formatMessage({ id: "member.squid_info.squid_settlement_number" }),
			render: (value: any, record: any) => <p>{record.settleHandNum}</p>,
			width: 150,
			align: "center",
			key: "settleHandNum"
		},
		{
			dataIndex: "venueTypeCode",
			title: formatMessage({ id: "member.squid_info.operate" }),
			render: (value: any, record: any) => {
				if (hasPermissionAction) {
					return <Link href={`/dxn/squidManager/squidDetail?tableCode=${record.tableCode}&round=${record.round}`}>鱿鱼详情</Link>
				}
				return <p>-</p>
			},
			width: 150,
			align: "center",
			key: "venueTypeCode"
		}
	]
}
